package com.cskaoyan.controller;

import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.vo.OrderSubmitVo;
import com.cskaoyan.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author zoe ling
 * @Date 2024/6/13
 */
@RestController
@RequestMapping("wx/order")
public class WxOrderController {
    @Autowired
    OrderService orderService;
    @PostMapping("submit")
    public BaseRespVo submit(@RequestBody OrderSubmitVo submitVo){
        Integer userId=1;
        Integer orderId=orderService.sumbit(userId,submitVo);
        if (orderId!=null){
            Map<String,Integer>data=new HashMap<>();
            data.put("orderId",orderId);
            return BaseRespVo.ok(data);
        }else {
            return BaseRespVo.fail("商品库存不足",100);
        }}}


